package com.accesshollywood.grfxOrdering.orderTreeSpecial.models;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JOptionPane;

import com.accesshollywood.grfxOrdering.basics.NamedList;
import com.accesshollywood.indexables.GrfxOrder;
import com.accesshollywood.indexables.items.GrfxItem;

public abstract class AbstractButtonPlusModel extends JButton {
	/*
	public NamedList	listing;
	public Object[]		selectedValues;
	public boolean		approved	= false;
	public GrfxOrder	grfxOrder;
	public GrfxItem		grfxItem;

	public AbstractButtonPlusModel() {
		super();
		this.setEnabled(false);
		listing = new NamedList();
	}

	public AbstractButtonPlusModel(String label) {
		super(label);
		this.setEnabled(false);
		listing = new NamedList();
	}

	public void setGrfxOrder(GrfxOrder grfxOrder) {
		this.grfxOrder = grfxOrder;
		this.listing.setGrfxOrder(grfxOrder);
	}

	public String getListingString() {
		return listing.toString();
	}

	public String getListingString(Object[] selectedValues) {
		String str = "";
		if (selectedValues != null) {
			for (int i = 0; i < selectedValues.length; i++) {
				str += selectedValues[i];
				if (selectedValues.length > 1 && i < selectedValues.length - 1) {
					str += "\n";
				}
			}
		}
		return str;
	}

	public class AddNoteActionListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			
		}
	}

	public class CopyToClipboardActionListener implements ActionListener, ClipboardOwner {

		public CopyToClipboardActionListener(Object[] selection) {
			// Object[] selection = list.getSelectedValues();
			if (selection == null || selection.length == 0) {
				selection = listing.toArray();
			}
			selectedValues = selection;
		}

		@Override
		public void actionPerformed(ActionEvent arg0) {
			StringSelection stringSelection = new StringSelection(getListingString(selectedValues));
			Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, this);
		}

		@Override
		public void lostOwnership(Clipboard arg0, Transferable arg1) {
			// do nothing
		}
	}

	public class OpenFolderActionListener implements ActionListener {

		public OpenFolderActionListener() {
		}

		@Override
		public void actionPerformed(ActionEvent arg0) {
			if (AbstractButtonPlusModel.this instanceof ButtonAndListModel) {
				if (listing != null && listing.name != null) {
					File f = new File(listing.name);

					if (f.exists()) {
						Runtime r = Runtime.getRuntime();
						try {
							r.exec("explorer.exe \"" + f.getAbsolutePath() + "\"");
						} catch (IOException e) {
							e.printStackTrace();
						}
					} else {
						JOptionPane.showMessageDialog(null, "WARNING!\nFOLDER   " + f.getAbsolutePath() + "   NOT FOUND.", "ERROR", JOptionPane.ERROR_MESSAGE);
					}
				} else {
					JOptionPane.showMessageDialog(null, "WARNING!  NO FOLDER SET.", "ERROR", JOptionPane.ERROR_MESSAGE);
				}
			}
		}
	}
	*/
}
